# Python 2.6.4
# Project Euler, Problem 30
# Copyright 2010 Talha Zaman

total = 0
for i in range(2,1000000):
    digits = sum([int(x)**5 for x in str(i)])
    if digits == i: total += digits
print total
